package librecalcdataproxy.server;

/**
 *
 * @author Wiktor Toporek
 */
public class EventExchanger {

        boolean buttonPressed;
        boolean waiting;

    public EventExchanger() {
        buttonPressed = false;
        waiting = false;
    }
    public void reset(){
        buttonPressed = false;
    }
    public void startWaiting(){
        waiting = true;
    }
    public void stopWaiting(){
        waiting = false;
    }
    public boolean isWaiting(){
        return waiting;
    }
    public synchronized void checkClick(){
        while(!buttonPressed){
            try {
                wait();
            } catch (InterruptedException ex) {
               
            }
        }
        buttonPressed = false;
        notifyAll();
    }
    
    public synchronized void setClick(){
        buttonPressed = true;
        notifyAll();
    }
            
            
        
}
